<!DOCTYPE html>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" >
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="Content-Language" content="zh-cn"/>
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
        <meta name='robots' content='noindex,nofollow' />
        <title>后台登录</title>
        <link rel="shortcut icon" type="image/x-icon" href="__ROOT_DIR__/favicon.ico?v={$version}" media="screen"/>
        <link href="__SKIN__/css/login.css?v={$version}" rel="stylesheet" type="text/css" />
        <link href="__SKIN__/font/css/iconfont.css?v={$version}" rel="stylesheet" type="text/css" />
        <link href="__SKIN__/css/diy_style.css?v={$version}" rel="stylesheet" type="text/css" />
        <style type="text/css">
            body {margin: 0;background:#69a2fe url(__PUBLIC__/static/admin/images/login-bg.png) center center no-repeat;background-attachment: fixed; background-size: cover;}
            .SignBox{position: relative;}
            .ercodeSignBox{position: relative;}
            .input-item{position: relative;}
            .input-item i{position: absolute;color: #999;top: 12px;}
            .input-item.focus i{color: #3672c8;}
            .container{width: 320px;}
            .box{width: 360px;padding: 35px 30px 30px 30px;box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);border-radius: 5px;background: rgba(255, 255, 255, 1);}
            .logo{margin-top: 120px;}
            .logo img {max-width: 402px;}
            .btn {display: block;}
            .btn:hover {background: #1d8def;border-color: #1d8def;}
            .chicuele{position:absolute; right: 0px;top: 3px;height: 37px;}
            .wechat {display: none;}
            @media only screen and (max-width: 768px){
                .container{width: 320px;}
                .input-item i{font-size: 16px;}
                .logo img {max-width: 320px;}
                .box{width: 320px;padding:20px;}
                .form-control {width: 100%;line-height: 28px;}
                .chicuele{height:36px;}
                .btn-lg{margin: 30px auto 0 auto;}
                .wechat {display: block;margin-top: 30px; text-align: right;}
                .wechat input {outline: 0;background: unset;border: unset;color: #428bff;font-size: 14px;text-align: right;}
            }
            .loading_vertify{height: 23px;right: 9px;top: 14px;}
            .input-item .password-icon{position: absolute;top: 17px;right: 8px;width: 18px;height: 18px;background-color: #ccc;z-index: 10;cursor: pointer;}
            .input-item .password-icon.show{background: url(__PUBLIC__/static/admin/images/password_show.png) no-repeat center center;}
            .input-item .password-icon.hide{background: url(__PUBLIC__/static/admin/images/password_hide.png) no-repeat center center;}
            .ercodecon{text-align: center;}
            .ercodepic img{width: 172px;height: 172px;}
            .ercodetie{font-size: 24px;color: #1a1a1a;line-height: 33px;margin-bottom: 20px;margin-top: 3px;}
            .ercodinof{font-size: 14px;line-height: 22px;color: #5E5E5E;}
            .swicth-ercode {display: inline-block;float: right;width: 40px;height: 40px;background-size: cover;position: absolute;top: 6px;right: 6px;cursor: pointer;}
            .switch-input {width: 40px;height: 40px;position: absolute;right: 6px;top: 6px;cursor: pointer;background-size: cover;}
            .swicth-ercode i, .switch-input i{font-size: 40px;color: #3672c8;}
        </style>
        {load href="__STATIC__/common/js/jquery.min.js" /}
        <script type="text/javascript" src="__SKIN__/js/jquery.SuperSlide.2.1.2.js"></script>
        <script type="text/javascript" src="__SKIN__/js/jquery.validation.min.js"></script>
        <script type="text/javascript" src="__SKIN__/js/jquery.cookie.js"></script>
        <script type="text/javascript" src="__PUBLIC__/plugins/layer-v3.1.0/layer.js"></script>
        <script type="text/javascript" src="__SKIN__/js/jquery.md5.js"></script>
        <!--[if lte IE 8]>
            <script type="Text/Javascript" language="JavaScript">
                function detectBrowser()
                {
                    var browser = navigator.appName
                    if(navigator.userAgent.indexOf("MSIE")>0){ 
                        var b_version = navigator.appVersion
                        var version = b_version.split(";");
                        var trim_Version = version[1].replace(/[ ]/g,"");
                        if ((browser=="Netscape"||browser=="Microsoft Internet Explorer"))
                        {
                            if(trim_Version == 'MSIE8.0' || trim_Version == 'MSIE7.0' || trim_Version == 'MSIE6.0'){
                                layer.alert('请使用IE9.0版本以上进行访问', {icon: 5, title:false});
                                return false;
                            }
                        }
                    }
               }
               detectBrowser();
            </script>
        <![endif]-->
        <script type="text/javascript">
            var eyou_basefile = "{$Request.baseFile}";
            var layer_shade = [0.7, '#fafafa'];
        </script>
    </head>

    <body>
        <div id="container">
            <div id="anitOut"></div>
        </div>
        <div class="container">
            <div class="logo">
                {notempty name="$is_eyou_authortoken"}
                <img src="{$global.web_loginlogo|handle_subdir_pic=###|default='__SKIN__/images/login-logo_ey.png'}?v={$time}">
                {else /}
                <img src="{$global.web_loginlogo|handle_subdir_pic=###|default='__SKIN__/images/login-logo_zy.png'}?v={$time}">
                {/notempty}
            </div>
            <div class="box SignBox">
                {if condition="!empty($wechat.appid) && !empty($wechat.appsecret) && !empty($mbackendConf['loginMode']) && in_array('userGzhLogin', $mbackendConf['loginMode']) && 1 == count($mbackendConf['loginMode'])"}
                    <input type="button" name="submit" class="btn btn-lg btn-primary btn-block show-dialog" value="微信授权登录" onclick="weChatAuthorization();">
                {else /}
                    <form action="" name='theForm' id="theForm" method="post">
                        <div class="input-item">
                            <i class="iconfont e-yonghu"></i>
                            <label for="inputEmail" class="sr-only">用户名</label>
                            <input type="text" name="user_name" autocomplete="off" class="form-control" value="" placeholder="用户名" required autofocus />
                        </div>
                        <div class="input-item">
                            <i class="iconfont e-mima"></i>
                            <label for="inputPassword" class="sr-only">密码</label>
                            <input type="password" name="password" autocomplete="off" class="form-control" value="" placeholder="密码" required />
                            <span class="password-icon hide pass-showhide" data-name="password"></span>
                        </div>
                        {eq name="$is_vertify" value="1"}
                       <div class="input-item">
                            <i class="iconfont e-yanzhengma"></i>
                            <input type="text" name="vertify" autocomplete="off" class="form-control" value="" placeholder="验证码" />
                            <img src="__STATIC__/common/images/loading.gif?v={$version}" class="chicuele loading_vertify" id="imgVerify" alt="" onclick="fleshVerify();" >
                        </div>
                        {/eq}
                        <input type="button" name="submit" class="btn btn-lg btn-primary btn-block show-dialog" value="登录">
                    </form>
                    {if condition="in_array('userGzhLogin', $mbackendConf['loginMode'])"}
                        {if condition="!empty($wechat.appid) && !empty($wechat.appsecret)"}
                        <div class="wechat">
                            <input type="button" value="使用微信授权登录" onclick="weChatAuthorization();" >
                        </div>
                        {/if}
                    {/if}
                {/if}
            </div>
        </div> <!-- /container -->
        <script type="text/javascript">
            // 微信授权登录
            function weChatAuthorization() {
                layer_loading('正在处理');
                $.ajax({
                    url : "{:url('Admin/ajax_admin_wechat_login')}",
                    data: {_ajax: 1, weappAjax: 1},
                    type: 'post',
                    dataType: 'json',
                    success: function(res) {
                        layer.closeAll();
                        if (res.code == 1) {
                            window.location.href = res.url;
                        } else {
                            layer.msg(res.msg, {time: 2000, icon: 5});
                        }
                    },
                    error: function(e) {
                        layer.closeAll();
                        showErrorAlert(e.responseText);
                    }
                });
            }

            function fleshVerify() {
                var src = "{:url('Admin/vertify', ['weappAjax'=>1])}";
                if (src.indexOf('?') > -1) {
                    src += '&';
                } else {
                    src += '?';
                }
                src += 't='+Math.floor(Math.random()*10000000);
                $('#imgVerify').attr('src', src);//重载验证码
            }

            /**
             * 封装的加载层
             */
            function layer_loading(msg){
                var loading = layer.msg(
                msg+'...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请勿刷新页面', 
                {
                    icon: 1,
                    time: 3600000, //1小时后后自动关闭
                    shade: [0.2] //0.1透明度的白色背景
                });
                //loading层
                var index = layer.load(3, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                });

                return loading;
            }
            
            $(function(){
                
                setTimeout(function(){
                    $('.loading_vertify').removeClass('loading_vertify').attr('src', '');
                    fleshVerify();
                },800);

                $(".form-control").focus(function(){
                    $(this).parent().addClass("focus");
                });
                
                $(".form-control").blur(function(){
                    $(this).parent().removeClass("focus");
                });

                $(document).keydown(function(event){
                    if(event.keyCode ==13){
                        $('#theForm input[name=submit]').trigger("click");
                    }
                });

                /**
                 * 明文密码
                 */
                $(".pass-showhide").attr('data-showOrHide', 'hide');
                $(".pass-showhide").on('click', function(){
                    var showOrHide = $(this).attr('data-showOrHide');
                    if ('hide' == showOrHide) {
                        $(this).attr('data-showOrHide', 'show');
                        var name = $(this).data('name');
                        $("input[name="+name+"]").get(0).type="text";
                        $(this).removeClass('hide').addClass('show');
                    } else {
                        $(this).attr('data-showOrHide', 'hide');
                        var name = $(this).data('name');
                        $("input[name="+name+"]").get(0).type="password";
                        $(this).removeClass('show').addClass('hide');
                    }
                });

                $('#theForm input[name=submit]').on('click',function(){
                    var user_name=true;
                    var password=true;
                    var vertify=true;

                    if($('#theForm input[name=user_name]').val() == ''){
                        layer.msg('用户名不能为空！', {time: 1000});
                        $('#theForm input[name=user_name]').focus();
                        user_name = false;
                        return false;
                    }

                    if($('#theForm input[name=password]').val() == ''){
                        layer.msg('密码不能为空！', {time: 1000});
                        $('#theForm input[name=password]').focus();
                        password = false;
                        return false;
                    }

                    var is_vertify = {$is_vertify|default=1};
                    if (1 == is_vertify) {
                        if($('#theForm input[name=vertify]').val() == ''){
                            layer.msg('验证码不能为空！', {time: 1000});
                            $('#theForm input[name=vertify]').focus();
                            vertify = false;
                            return false;
                        }
                    }

                    if(vertify && $('#theForm input[name=user_name]').val() != '' && $('#theForm input[name=password]').val() != ''){
                        var url = "{:url('Admin/login', ['_ajax'=>1])}";
                        if (url.indexOf('?') > -1) {
                            url += '&';
                        } else {
                            url += '?';
                        }
                        url += 't='+Math.random();
                        var formData = $('#theForm').serialize();
                        // var md5_password = $.md5($('input[name=password]').val());
                        // formData = replaceParamVal(formData, 'password', md5_password);
                        layer_loading('准备进入');
                        $.ajax({
                            async:false,
                            url: url,
                            data: formData,
                            type:'post',
                            dataType:'json',
                            success:function(res){
                                if(1 == res.code){
                                    top.location.href = res.url;
                                }else{
                                    layer.closeAll();
                                    fleshVerify();
                                    user_name=false;
                                    password=false;
                                    layer.alert(res.msg, {icon: 5, title:false, closeBtn: false});
                                    return false;
                                }
                            },
                            error : function(e) {
                                layer.closeAll();
                                layer.alert(e.responseText, {icon: 5, title:false, closeBtn: false});
                            }
                        });
                    }else{
                        return false;
                    }
                });

                clear_session();
                function clear_session()
                {
                    $.ajax({
                        url: "__ROOT_DIR__/index.php?m=api&c=Ajax&a=clear_session",
                        type: 'post',
                        dataType: 'JSON',
                        data: {_ajax: 1},
                        success: function(res){
                        }
                    });
                }
            });

            //替换指定传入参数的值,paramName为参数,replaceWith为新值
            function replaceParamVal(querystr, paramName, replaceWith) {
                var re=eval('/('+ paramName+'=)([^&]*)/gi');
                querystr = querystr.replace(re,paramName+'='+replaceWith);
                return querystr;
            }
        </script>

        {include file="public/footer" /}
